#include <linux/pci.h>
#include <linux/platform_device.h> 
#include <linux/irq.h>  
#include <linux/log2.h> 
#include <linux/module.h>
#include <linux/moduleparam.h> 
#include <linux/slab.h> 
#include <linux/dmi.h> 
#include <linux/pci.h>
#include <linux/rwsem.h>
#include <linux/wakelock.h>
#include <acpi/acpi.h>
#include <linux/dbg_tool.h>
#include "pm_dbg.h"

struct pm_dev_wakelock_d {
	struct device dev;
	//struct wakelock wake_l;
	struct wake_lock	wake_l;	/* for add time-delay */
};

struct pm_dev_wakelock_d *pm_dev_wd;
static ssize_t
pm_dbg_show(struct device *pdev, struct device_attribute *attr, char *buf)
{ 
   return 0;
}

static ssize_t
pm_dbg_store(struct device *pdev, struct device_attribute *attr,
		    const char *buff, size_t size)
{
    return 0;
}

static DEVICE_ATTR(pm_dbg,S_IRUGO | S_IWUSR, pm_dbg_show , pm_dbg_store);
int pm_dev_wake_lock_entry(void)
{
	struct device *dev;
	int ret;
	//wake_lock_timeout(&hcd->wake_lock, 5 * HZ);

	pm_dev_wd = kmalloc(sizeof(struct pm_dev_wakelock_d), GFP_KERNEL);
	wake_lock(&pm_dev_wd->wake_l);
	dev = &pm_dev_wd->dev;
    device_initialize(dev);
    dev->init_name = "pm_dev_wakelock";
    dev->bus = NULL;
    dev->type = NULL;
    dev->groups = NULL;
    ret = device_add(dev);
    if (ret)
    {
		printk("%s add dev fail:%d\n" ,__func__ , ret);
		return 1;
	}
    ret = device_create_file(dev ,&dev_attr_pm_dbg);
    if (ret)
    {
		printk("%s add dev fail:%d\n" ,__func__ , ret);
		return 1;
	}
	return 0;
}

void pm_dev_wake_lock_exit(void)
{
    device_remove_file(&pm_dev_wd->dev ,&dev_attr_pm_dbg);
	device_del(&pm_dev_wd->dev);
	put_device(&pm_dev_wd->dev);
	wake_unlock(&pm_dev_wd->wake_l);
	kfree(pm_dev_wd);
}

